package 蓝桥真题;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.time.LocalDate;

public class 回文日期 {
       static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
       
       static boolean check1(String d){
    	      for(int i=0,j=7;i<j;i++,j--){
    	    	  if(d.charAt(i)!=d.charAt(j))
    	    		  return false;
    	      }
    	      return true;
       }
       static boolean check2(String d){
    	      return (d.charAt(0)==d.charAt(2)&&d.charAt(1)==d.charAt(3));
       }
       public static void main(String[]args)throws Exception{
    	      String date=br.readLine();
    	      int year=Integer.parseInt(date.substring(0, 4));
    	      int month=Integer.parseInt(date.substring(4, 6));
    	      int day=Integer.parseInt(date.substring(6, 8));
    	      LocalDate ld = LocalDate.of(year, month, day);
    	      ld.plusDays(1L);
    	      boolean f1=true,f2=true;
    	      while(f1||f2){
    	    	    String d=ld.toString().replace("-", "");
    	    	    if(check1(d)){
    	    	    	if(f1){
    	    	    		System.out.println(d);
        	    	    	f1=false;
    	    	    	}
    	    	    	if(check2(d)){
    	    	    		System.out.println(d);
        	    	    	f2=false;
    	    	    	}
    	    	    }
    	    	    ld = ld.plusDays(1L);
    	      }
    	      br.close();
       }
}
